/**
 * 
 */
package com.wissen.giskard.server.payroll.impl;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.wissen.giskard.client.data.SalaryDTO;
import com.wissen.giskard.client.payroll.services.DisplayTableService;
import com.wissen.giskard.server.domainobjects.SalarySlip;
import com.wissen.giskard.server.payroll.services.GetPayRoll;

/**
 * @author Swapnil Sonawane
 *
 * @created date :06-Aug-2010
 */

@SuppressWarnings("serial")
public class DisplayTableServiceImpl extends RemoteServiceServlet implements DisplayTableService{

	/**
	 * 
	 */
	
	
	@Override
	public  List<SalaryDTO> DisplayTable() throws IllegalArgumentException {
		
		
		List<SalarySlip> payRollList=null;
		String[][] payrollArray = new String[10][4];
		List<SalaryDTO> records=new ArrayList<SalaryDTO>();
		
		try{
			
			GetPayRoll getpayroll= new GetPayRoll();
			payRollList=getpayroll.getPayRollList();
			for(SalarySlip salarySlip:payRollList)
			{
				SalaryDTO salarydto = new SalaryDTO();
				salarydto.setSalary_Id(salarySlip.getSalary_Id());
				salarydto.setEmp_Name(salarySlip.getName());
				salarydto.setMonth(salarySlip.getMonth());
				salarydto.setTotal_salary(salarySlip.getBasicSalary()+salarySlip.getBonus1()+salarySlip.getBonus2()-salarySlip.getDeduction1()-salarySlip.getDeduction2());
				if(salarySlip.getPaid()==true)
					salarydto.setPaid("true");
				else
					salarydto.setPaid("false");
					
				
				records.add(salarydto);
			}
		}
		catch(Exception e){
		
		}
		
		
		return records;
	}

	
	
	public  boolean CheckEnable(boolean result) {
		if(result==true)
			return true;
		return false;
	}

}
